package com.ticket.sass.admin.dto.output.commodity;

import com.ticket.sass.admin.model.KeyInfoModel;
import com.ticket.sass.common.entity.tenant.CommoditySkuEntity;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;

import java.math.BigDecimal;
import java.util.List;
import java.util.Map;

/**
 * @author ywb
 * @date 2024-03-23 14:17
 */
@Data
@ApiModel(value = "卖品 SKU", description = "按照要求填写")
public class CommoditySkuOutput {
    @ApiModelProperty(value = "ID", required = true)
    private Long id;
    
    @ApiModelProperty(value = "封面图", required = true)
    private List<KeyInfoModel> cover;
    
    @ApiModelProperty(value = "卖品售价", required = true)
    private BigDecimal salePrice;
    
    @ApiModelProperty(value = "卖品市场价")
    private BigDecimal marketPrice;
    
    @ApiModelProperty(value = "库存", required = true)
    private Integer stockNum;
    
    @ApiModelProperty(value = "发布状态：0 未发布，1已发布")
    private Integer publishStatus;
    
    @ApiModelProperty(value = "外部sku编码")
    private String externalCode;
    
    @ApiModelProperty(value = "属性值对 示例 {  " +
        "  \"分量\": \"大杯\",  " +
        "  \"温度\": \"标准冰\",  " +
        "  \"甜度\": \"很甜\"  " +
        "} ", required = true)
    private Map<String, String> attrMap;
    
    public CommoditySkuOutput() {
    }
    
    public CommoditySkuOutput(CommoditySkuEntity entity) {
        this.id = entity.getId();
        this.cover = KeyInfoModel.generationList(entity.getCover());
        this.salePrice = entity.getSalePrice();
        this.marketPrice = entity.getMarketPrice();
        this.stockNum = entity.getStockNum();
        this.publishStatus = entity.getPublishStatus();
        this.externalCode = entity.getExternalCode();
    }
}
